/** @format */
import { services, checkParams, noCheckUser, registeInfos } from '../../decorator/common'
import { resultsModel } from '../../sdk'
import {
  CommonUserService,
  CommonBaseService,
} from '../../service/common'
import { DRAW_STATUS, STAT_TYPE } from '../../constants'
import { CODE_TYPES } from '../../errorCode'
import { noCheckActivityInfo } from '../../decorator/common/noCheckUser'

export default class LoginController {
  /**
   *  登录接口, 初始化/更新用户信息
   */
  @checkParams(['earlybird_id', 'shop_id'])
  @noCheckUser
  @noCheckActivityInfo
  @services([CommonUserService])
  async register(
    context: IContext<IParams>,
    {}: IControllerInfos,
    [commonUserService]: [CommonUserService]
  ) {
    const { earlybird_id, shop_id } = context.data
    const commonUserDoLoginResult1 = await commonUserService.registerInfo(earlybird_id, shop_id)
    return resultsModel.success(commonUserDoLoginResult1)
  }

  @checkParams(['activityId', 'envType?'])
  @noCheckUser
  @noCheckActivityInfo
  @services([CommonBaseService])
  async getEnvConfig(context: IContext<IParams>, {}: IControllerInfos, [commonBaseService]: [CommonBaseService]) {
    const commonBaseGetBaseInfoResult1: any = await commonBaseService.getEnvConfig()
    return resultsModel.success({
      ...commonBaseGetBaseInfoResult1
    })
  }
}
